package com.xuhf.conf;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConf {

    public final static String GPS_HISTORY_COLLECT_QUEUE = "gpsHistoryCollectQueue";

    public final static String GPS_HISTORY_COLLECT_ROUTING = "gpsHistoryCollectRouting";

    public final static String GPS_TODAY_COLLECT_QUEUE = "gpsTodayCollectQueue";

    public final static String GPS_TODAY_COLLECT_ROUTING = "gpsTodayCollectRouting";

    public final static String AREA_HISTORY_COLLECT_QUEUE = "areaHistoryCollectQueue";

    public final static String AREA_HISTORY_COLLECT_ROUTING = "areaHistoryCollectRouting";

    public final static String AREA_TODAY_COLLECT_QUEUE = "areaTodayCollectQueue";

    public final static String AREA_TODAY_COLLECT_ROUTING = "areaTodayCollectRouting";

    public final static String PIC_HISTORY_COLLECT_QUEUE = "picHistoryCollectQueue";

    public final static String PIC_HISTORY_COLLECT_ROUTING = "picHistoryCollectRouting";

    public final static String PIC_TODAY_COLLECT_QUEUE = "picTodayCollectQueue";

    public final static String PIC_TODAY_COLLECT_ROUTING = "picTodayCollectRouting";

    public final static String REALTIME_AREA_COMPUTING_QUEUE = "realtimeAreaComputingQueue";

    public final static String REALTIME_AREA_COMPUTING_ROUTING = "realtimeAreaComputingRouting";

    public final static String GPS_EXCHANGE = "gps_exchange";

    @Bean
    DirectExchange gpsExchange() {
        return new DirectExchange(GPS_EXCHANGE, true, false);
    }

    @Bean
    public Queue gpsHistoryCollectQueue() {
        return new Queue(GPS_HISTORY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingGpsHistoryCollectDirect() {
        return BindingBuilder.bind(gpsHistoryCollectQueue()).to(gpsExchange()).with(GPS_HISTORY_COLLECT_ROUTING);
    }

    @Bean
    public Queue gpsTodayCollectQueue() {
        return new Queue(GPS_TODAY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingGpsTodayCollectDirect() {
        return BindingBuilder.bind(gpsTodayCollectQueue()).to(gpsExchange()).with(GPS_TODAY_COLLECT_ROUTING);
    }

    @Bean
    public Queue areaHistoryCollectQueue() {
        return new Queue(AREA_HISTORY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingAreaHistoryCollectDirect() {
        return BindingBuilder.bind(areaHistoryCollectQueue()).to(gpsExchange()).with(AREA_HISTORY_COLLECT_ROUTING);
    }

    @Bean
    public Queue areaTodayCollectQueue() {
        return new Queue(AREA_TODAY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingAreaTodayCollectDirect() {
        return BindingBuilder.bind(areaTodayCollectQueue()).to(gpsExchange()).with(AREA_TODAY_COLLECT_ROUTING);
    }

    @Bean
    public Queue picHistoryCollectQueue() {
        return new Queue(PIC_HISTORY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingPicHistoryCollectDirect() {
        return BindingBuilder.bind(picHistoryCollectQueue()).to(gpsExchange()).with(PIC_HISTORY_COLLECT_ROUTING);
    }

    @Bean
    public Queue picTodayCollectQueue() {
        return new Queue(PIC_TODAY_COLLECT_QUEUE, true);
    }

    @Bean
    Binding bindingPicTodayCollectDirect() {
        return BindingBuilder.bind(picTodayCollectQueue()).to(gpsExchange()).with(PIC_TODAY_COLLECT_ROUTING);
    }

    @Bean
    public Queue realtimeAreaComputingQueue() {
        return new Queue(REALTIME_AREA_COMPUTING_QUEUE, true);
    }

    @Bean
    Binding bindingRealtimeAreaComputingDirect() {
        return BindingBuilder.bind(realtimeAreaComputingQueue()).to(gpsExchange()).with(REALTIME_AREA_COMPUTING_ROUTING);
    }
}
